package org.deltaset.faces.component;

import java.util.Collections;
import java.util.List;
import javax.faces.component.UIComponent;
import javax.faces.component.UINamingContainer;

/**
 *
 * @author dmakariev
 */
public class CachedChildrenNamingContainer extends UINamingContainer {

    private CachingUIComponentList cachedChildren = null;

    @Override
    public List<UIComponent> getChildren() {
        if (null == cachedChildren) {
            cachedChildren = new CachingUIComponentList(super.getChildren());
        }
        return cachedChildren;
    }

    public List<UIComponent> getCachedChildren() {
        if (null == cachedChildren) {
            return Collections.emptyList();
        }
        return cachedChildren.allChildren();
    }
}
